package com.reps.service;

import org.dom4j.Element;

import java.util.List;

/**
 * Created by john on 2018/7/21.
 */
public class PrcessValue {


    public static void processTwoParameterAfter(int index,OutInfo myvalue,String[] win_value) throws Exception
    {

        if(index==17)//1 复选框 老年人认知功能
        {
            int win_id=Integer.valueOf(win_value[1].replace("dx","").replace("_",""));
            myvalue.record+=SetValueTemplate.getMultiCheckboxValueString(win_id+1,1)+";";
        }else if(index==24 ||index==27 ||index==30 || index==33)//粉尘等防护措施有无 复选框
        {
            int win_id=Integer.valueOf(win_value[1].replace("dx","").replace("_",""));
            myvalue.record+=SetValueTemplate.getMultiCheckboxValueString(win_id+2,1)+";";
        }
        else if(index==36)//其他 防护措施 后的 锻炼频率单选框
        {
            int win_id=Integer.valueOf(win_value[1].replace("dx","").replace("_",""));
            myvalue.record+=SetValueTemplate.getMultiCheckboxValueString(win_id+2,1)+";";
        }
           else if(index==37)//其他 防护措施 后的 锻炼频率单选框
        {
            int win_id=3+Integer.valueOf(win_value[1].replace("dx","").replace("_",""));
            myvalue.record+=SetValueTemplate.getSelectedSingleBox(win_id,4)+";";
        }
       else if(index==40)//锻炼方式 后的 饮食习惯6个复选框
        {
            int win_id=Integer.valueOf(win_value[1].replace("dx","").replace("_",""));
            myvalue.record+=SetValueTemplate.getMultiCheckboxValueString(win_id+1,6)+";";
        }else if(index==43)//戒烟年龄 后的 4个单选框    饮酒频率
        {
            int win_id=3+Integer.valueOf(win_value[1].replace("dx","").replace("_",""));
            myvalue.record+=SetValueTemplate.getSelectedSingleBox(win_id,4)+";";
        }else if(index==44)//2个单选框 是否戒酒
        {
            int win_id=3+Integer.valueOf(win_value[1].replace("dx","").replace("_",""));

            List<Element> value1=SetValueTemplate.getOneValueByWinId2(win_id);
            List<Element> value2=SetValueTemplate.getOneValueByWinId2(win_id+1);
            if(value1!=null && value2!=null && value1.size()<value2.size())
                myvalue.record+="否;";
            else
                myvalue.record+="是;";



        }else if(index==46)//2个单选框 近一年内是否醉酒; 4个复选框 饮酒种类
        {
            int win_id=3+Integer.valueOf(win_value[1].replace("dx","").replace("_",""));
          // myvalue.record+=SetValueTemplate.getSelectedSingleBox(win_id,2)+";";

            List<Element> value1=SetValueTemplate.getOneValueByWinId2(win_id);
            List<Element> value2=SetValueTemplate.getOneValueByWinId2(win_id+1);
            if(value1!=null && value2!=null && value1.size()<value2.size())
                myvalue.record+="否;";
            else
                myvalue.record+="是;";

            win_id+=2;
            myvalue.record+=SetValueTemplate.getMultiCheckboxValueString2(win_id,4)+";";

        }else if(index==47)//2个单选框 有无职业病危害因素接触史
        {
            int win_id=3+Integer.valueOf(win_value[1].replace("dx","").replace("_",""));
            myvalue.record+=SetValueTemplate.getSelectedSingleBox(win_id,2)+";";
        }else if(index==49)//5个单选框 口唇,4         齿列,3         咽部
        {
            int win_id=16+Integer.valueOf(win_value[1].replace("dx","").replace("_",""));
            myvalue.record+=SetValueTemplate.getSelectedSingleBox(win_id,5)+";";
            win_id+=7;
            myvalue.record+=SetValueTemplate.getSelectedSingleBox(win_id,4)+";";
            win_id+=6;
            myvalue.record+=SetValueTemplate.getSelectedSingleBox(win_id,3)+";";
        }else if(index==53)//2个单选框 听力,2         运动功能
        {
            int win_id=Integer.valueOf(win_value[1].replace("dx","").replace("_",""));
            if(SetValueTemplate.getSelectedSingleBox(win_id+3,2)==0)
                  myvalue.record+="听见"+";";
            else
                myvalue.record+="听不清或无法听见"+";";

            if(SetValueTemplate.getSelectedSingleBox(win_id+7,2)==0)
                myvalue.record+="可顺利完成"+";";
            else
                myvalue.record+="无法独立完成其中任何一个动作"+";";

            int value3=SetValueTemplate.getSelectedSingleBox(win_id+14,3);
            if(value3==0)
                myvalue.record+="未检查"+";";
            else if(value3==1)
                myvalue.record+="正常"+";";
            else
                myvalue.record+="异常"+";";
        }else if(index==54)//眼底异常情况,8 单选 皮肤
        {
          int win_id=Integer.valueOf(win_value[1].replace("dx","").replace("_",""));
          myvalue.record+=SetValueTemplate.getSelectedSingleBox(win_id+32,8)+";";

       }else if(index==55)//8 单选 皮肤,5个单选框 巩    膜
        {
            int win_id=Integer.valueOf(win_value[1].replace("dx","").replace("_",""));
            myvalue.record+=SetValueTemplate.getSelectedSingleBox(win_id+3,5)+";";
        }else if(index==56)//5个单选框 淋巴结
        {
            int win_id=Integer.valueOf(win_value[1].replace("dx","").replace("_",""));
            myvalue.record+=SetValueTemplate.getSelectedSingleBox(win_id+3,5)+";";
        }else if(index==57)//3个单选  肺 桶状胸 ,3           呼吸音
        {
            int win_id=Integer.valueOf(win_value[1].replace("dx","").replace("_",""));
            myvalue.record+=SetValueTemplate.getSelectedSingleBox(win_id+3,3)+";";
            myvalue.record+=SetValueTemplate.getSelectedSingleBox(win_id+8,3)+";";
        }else if(index==58)//5个单选   罗音
        {
            int win_id=Integer.valueOf(win_value[1].replace("dx","").replace("_",""));
            myvalue.record+=SetValueTemplate.getSelectedSingleBox(win_id+3,5)+";";
        }else if(index==60)//4个单选框 心脏心律, 3    单选     心脏杂音
        {
            int win_id=Integer.valueOf(win_value[1].replace("dx","").replace("_",""));
            myvalue.record+=SetValueTemplate.getSelectedSingleBox(win_id+3,4)+";";
            myvalue.record+=SetValueTemplate.getSelectedSingleBox(win_id+9,3)+";";
        }else if(index==61)//3单选   腹部：压痛
        {
            int win_id=Integer.valueOf(win_value[1].replace("dx","").replace("_",""));
            myvalue.record+=SetValueTemplate.getSelectedSingleBox(win_id+3,3)+";";
        }else if(index==62)//3 单选 包块
        {
            int win_id=Integer.valueOf(win_value[1].replace("dx","").replace("_",""));
            myvalue.record+=SetValueTemplate.getSelectedSingleBox(win_id+3,3)+";";
        }else if(index==63)//3  单选  腹部：肝大
        {
            int win_id=Integer.valueOf(win_value[1].replace("dx","").replace("_",""));
            myvalue.record+=SetValueTemplate.getSelectedSingleBox(win_id+3,3)+";";
        }else if(index==64)//3  单选  腹部：脾大
        {
            int win_id=Integer.valueOf(win_value[1].replace("dx","").replace("_",""));
            myvalue.record+=SetValueTemplate.getSelectedSingleBox(win_id+3,3)+";";
        }else if(index==65)//3  单选 腹部：移动性浊音
        {
            int win_id=Integer.valueOf(win_value[1].replace("dx","").replace("_",""));
            myvalue.record+=SetValueTemplate.getSelectedSingleBox(win_id+3,3)+";";
        }else if(index==66)//5   单选 下肢水肿,5    单选 足背动脉搏动,6   单选  肛门指诊
        {
            int win_id=Integer.valueOf(win_value[1].replace("dx","").replace("_",""));
            myvalue.record+=SetValueTemplate.getSelectedSingleBox(win_id+3,5)+";";
            myvalue.record+=SetValueTemplate.getSelectedSingleBox(win_id+10,5)+";";
            myvalue.record+=SetValueTemplate.getSelectedSingleBox(win_id+17,6)+";";
        }else if(index==67)//5 复选框  乳腺
        {
            int win_id=Integer.valueOf(win_value[1].replace("dx","").replace("_",""));
            myvalue.record+=SetValueTemplate.getMultiCheckboxValueString(win_id+1,5)+";";
        }else if(index==68)//1 复选框 妇科：外阴
        {
            int win_id=Integer.valueOf(win_value[1].replace("dx","").replace("_",""));
            myvalue.record+=SetValueTemplate.getMultiCheckboxValueString(win_id+1,1)+";";
        }else if(index==69)// 1 复选框 妇科：阴道
        {
            int win_id=Integer.valueOf(win_value[1].replace("dx","").replace("_",""));
            myvalue.record+=SetValueTemplate.getMultiCheckboxValueString(win_id+1,1)+";";
        }else if(index==70)//1 复选框 妇科：宫颈
        {
            int win_id=Integer.valueOf(win_value[1].replace("dx","").replace("_",""));
            myvalue.record+=SetValueTemplate.getMultiCheckboxValueString(win_id+1,1)+";";
        }else if(index==71)//1 复选框 妇科：宫体
        {
            int win_id=Integer.valueOf(win_value[1].replace("dx","").replace("_",""));
            myvalue.record+=SetValueTemplate.getMultiCheckboxValueString(win_id+1,1)+";";
        }else if(index==72)//1 复选框 妇科：附件
        {
            int win_id=Integer.valueOf(win_value[1].replace("dx","").replace("_",""));
            myvalue.record+=SetValueTemplate.getMultiCheckboxValueString(win_id+1,1)+";";
        }else if(index==73)//文本框  妇科：其他
        {
            int win_id=Integer.valueOf(win_value[1].replace("dx","").replace("_",""));
            //获取文本框的值
            myvalue.record+=SetValueTemplate.getOneValueByWinId(win_id+1)+";";
        }    //第四页
        else if(index==84)//1 复选框 心电图：正常
        {
            int win_id=Integer.valueOf(win_value[1].replace("dx","").replace("_",""));
            myvalue.record+=SetValueTemplate.getMultiCheckboxValueString(win_id+3,1)+";";
        }else if(index==107)//1 复选框 胸部x线片：正常
        {
            int win_id=Integer.valueOf(win_value[1].replace("dx","").replace("_",""));
            myvalue.record+=SetValueTemplate.getMultiCheckboxValueString(win_id+3,1)+";";
        }else if(index==108)
        {
            int win_id=Integer.valueOf(win_value[1].replace("dx","").replace("_",""));
            myvalue.record+=SetValueTemplate.getMultiCheckboxValueString(win_id+2,1)+";";
        }else if(index==109)
        {
            int win_id=Integer.valueOf(win_value[1].replace("dx","").replace("_",""));
            myvalue.record+=SetValueTemplate.getMultiCheckboxValueString(win_id+2,1)+";";
        }else if(index==110)
        {
            int win_id=Integer.valueOf(win_value[1].replace("dx","").replace("_",""));
            //获取文本框的值
            myvalue.record+=SetValueTemplate.getOneValueByWinId(win_id+2)+";";
        }else if(index==120)//5个复选框  肾脏疾病
        {
            int win_id=Integer.valueOf(win_value[1].replace("dx","").replace("_",""));
            myvalue.record+=SetValueTemplate.getMultiCheckboxValueString(win_id+1,5)+";";
        }else if(index==121)//5个复选框 心脏疾病
        {
            int win_id=Integer.valueOf(win_value[1].replace("dx","").replace("_",""));
            myvalue.record+=SetValueTemplate.getMultiCheckboxValueString(win_id+1,5)+";";
        }else if(index==122)//3个复选框 血管疾病
        {
            int win_id=Integer.valueOf(win_value[1].replace("dx","").replace("_",""));
            myvalue.record+=SetValueTemplate.getMultiCheckboxValueString(win_id+1,3)+";";
        }else if(index==123)//4个复选框  眼部疾病
        {
            int win_id=Integer.valueOf(win_value[1].replace("dx","").replace("_",""));
            myvalue.record+=SetValueTemplate.getMultiCheckboxValueString(win_id+1,4)+";";
        }else if(index==124)//3个单选框 神经系统疾病
        {
            int win_id=Integer.valueOf(win_value[1].replace("dx","").replace("_",""));
            myvalue.record+=SetValueTemplate.getSelectedSingleBox(win_id+3,3)+";";
        }else if(index==125)//3个单选框 其他系统疾病
        {
            int win_id=Integer.valueOf(win_value[1].replace("dx","").replace("_",""));
            myvalue.record+=SetValueTemplate.getSelectedSingleBox(win_id+3,3)+";";
        }else if(index==126)//入院时间1,出院时间1
        {
            int win_id=Integer.valueOf(win_value[1].replace("dx","").replace("_",""));
            myvalue.record+=SetValueTemplate.getOneValueByWinId(win_id+17)+";";
            myvalue.record+=SetValueTemplate.getOneValueByWinId(win_id+18)+";";

        }else if(index==129)//入院时间2,出院时间2
        {
            int win_id=Integer.valueOf(win_value[1].replace("dx","").replace("_",""));
            myvalue.record+=SetValueTemplate.getOneValueByWinId(win_id+1)+";";
            myvalue.record+=SetValueTemplate.getOneValueByWinId(win_id+2)+";";

        }else if(index==132 || index==135)//建床日期1 撤床日期1
        {
            int win_id=Integer.valueOf(win_value[1].replace("dx","").replace("_",""));
            myvalue.record+=SetValueTemplate.getOneValueByWinId(win_id+1)+";";
            myvalue.record+=SetValueTemplate.getOneValueByWinId(win_id+2)+";";

        }else if(index==169 || index==171 || index==173)//接种日期1 2 3
        {
            int win_id=Integer.valueOf(win_value[1].replace("dx","").replace("_",""));
            myvalue.record+=SetValueTemplate.getOneValueByWinId(win_id+1)+";";
        }else if(index==174)//2个单选框 体检有没有异常
        {
            int win_id=Integer.valueOf(win_value[1].replace("dx","").replace("_",""));
            myvalue.record+=SetValueTemplate.getSelectedSingleBox(win_id+8,2)+";";
        }else if(index==178)//3个复选框 健康指导建议,危险因素控制：5个复选框 和 79649 79651 两个复选框放一块
        {
            int win_id=Integer.valueOf(win_value[1].replace("dx","").replace("_",""));
            myvalue.record+=SetValueTemplate.getMultiCheckboxValueString(win_id+5,3)+";";
            myvalue.record+=SetValueTemplate.getMultiCheckboxValueString(win_id+8,5);
            myvalue.record+=SetValueTemplate.getMultiCheckboxValueString(win_id+14,1)+",";
            myvalue.record+=SetValueTemplate.getMultiCheckboxValueString(win_id+16,1)+";";
        }
    }






    public static boolean processFiveParameterBefore(int index, OutInfo myvalue, List<Element> temp, String[] win_value) throws Exception
    {
       boolean flag=false;//是否找到任意一个符合条件的执行项
        if(index==1)//性别
        {
            myvalue.record+=temp.get(0).getText().split("&")[1]+";";
            flag=true;
        }
        if(index==4)//出生日期，体检日期
        {

            myvalue.record+=temp.get(0).getText().replace("&","-").replace("-00-00-00","")+";";
            int win_id=Integer.valueOf(win_value[1].replace("dx","").replace("_","").trim());
            myvalue.record+=SetValueTemplate.getOneValueByWinId(win_id+1).replace("&","-").replace("-00-00-00","")+";";
            flag=true;
        }else  if(index==5)//责任医生
        {
            if(temp.size()==2 && temp.get(0).getText().contains("&"))
                myvalue.record+=temp.get(0).getText().split("&")[1]+";";
            else
                myvalue.record+=";";
            flag=true;
        }
        else  if(index==21 || index==22)
        {
            String value20=temp.get(0).getText();
            if(value20.contains("&"))
            {
                if(value20.split("&").length>=2)
                {
                    myvalue.record+=value20.split("&")[1]+";";
                }else{
                    myvalue.record+=value20.split("&")[0]+";";
                }
            }
            else
                myvalue.record+=value20+";";
            flag=true;
        }

        return flag;

    }

    public static void processFiveParameterAfter(int index,OutInfo myvalue,String[] win_value) throws Exception
    {



    }






}
